package cn.kgc.controller;

import cn.kgc.entity.Tag;
import cn.kgc.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author mosin
 * date 2022/1/16
 * @version 1.0
 */
@RestController
@RequestMapping("/tags")
public class TagController {
    @Autowired
    private TagService tagService;

    //查询 标签列表
    @GetMapping
    public List<Tag> getAll(){
       return tagService.getAll();

    }

    //删除标签
    @DeleteMapping("/{id}")
    public void delTag(@PathVariable Integer id){
        tagService.delTagById(id);
    }


    //添加标签
    @PostMapping
    public Tag addTag(@RequestBody Tag tag){
        return  tagService.addTag(tag);
    }

    //根据id 查询标签
    @GetMapping("/{id}")
    public  Tag getOne(@PathVariable Integer id){
        Tag tag = tagService.selectOne(id);
        return  tag;
    };


}
